package scau.hotel.hotel_web.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import scau.hotel.hotel_sys.service.ISysUserService;

@RestController
public class  TestController {
    @Autowired
    private ISysUserService sysUserService;

    @GetMapping("/login")
    public String index(){
        return "Hello SpringSecurity";
    }

    @PreAuthorize("hasAuthority('admin')")
    @GetMapping("/test1")
    public String test1(){
        return "authorize ADMIN request";
    }

    @PreAuthorize("hasAuthority('normal')")
    @GetMapping("/test2")
    public String test2(){
        return "authorize USER request";
    }

    @PreAuthorize("hasAnyAuthority('admin','normal')")
    @GetMapping("/test3")
    public String test3(){
        return "authorize ADMIN or USER request";
    }
}